#include <iostream>
#include <conio.h>
#include <Windows.h>
#include <process.h>

void threadFunc(void *p)
{
	using namespace std;
    cout << "\tthreadFunc started" << endl;
    cout << "\t";
	for (size_t i = 1; i <= 10; ++i)
	{
		Sleep(1000);
		cout << i << ' ';
	}
	cout << endl;
    cout << "\tthreadFunc finished" << endl;
    _endthread();
}

int main()
{
	HANDLE hThread;
	using namespace std;
	cout << "creating thread" << endl;
	hThread = (HANDLE)_beginthread( threadFunc, 0, NULL);
	cout << "waiting for thread execution end" << endl;
	WaitForSingleObject( hThread, INFINITE );
	cout << "thread execution finished, exiting" << endl;

	cout << "press any key to exit (getch test)..." << endl;
	getch();
	return 0;
}